﻿using System;

namespace DLMemberPointMS.Web.Configs
{
    /// <summary>
    /// 日志类
    /// </summary>
    public class LogHelper
    {
        private static readonly log4net.ILog loginfo = log4net.LogManager.GetLogger("loginfo");
        private static readonly log4net.ILog logerror = log4net.LogManager.GetLogger("logerror");
        private static readonly log4net.ILog logmonitor = log4net.LogManager.GetLogger("logmonitor");
        private static readonly log4net.ILog log_db = log4net.LogManager.GetLogger("logadonet");

        /// <summary>
        /// 错误日志
        /// </summary>
        /// <param name="errorMsg">错误信息</param>
        /// <param name="ex">异常</param>
        public static void Error(string errorMsg, Exception ex = null)
        {
            logerror.Error(errorMsg, ex);
        }
        /// <summary>
        /// 普通日志
        /// </summary>
        /// <param name="msg">信息</param>
        public static void Info(string msg)
        {
            loginfo.Info(msg);
        }


        /// <summary>
        /// 监控日志
        /// </summary>
        /// <param name="msg">信息</param>
        public static void Monitor(string msg)
        {
            logmonitor.Info(msg);
        }

        #region 写入日志到数据库  http://blog.csdn.net/kongwei521/article/details/52242319
        public static void ErrorToDB(object message, Exception ex = null)
        {
            log_db.Error(message, ex);
        }

        public static void InfoToDB(object message, Exception ex = null)
        {
            log_db.Info(message, ex);
        }
        #endregion

    }
}